library(rgl)
knitr::knit_hooks$set(webgl = hook_webgl)
We start from checking Inkscape installation
result <- st_read("./Red_Bird.shp")
## Reading layer `Red_Bird' from data source
## `C:\Users\jacek\JacekPardyak.github.io\inkscaper\Red_Bird.shp'
## using driver `ESRI Shapefile'
## Simple feature collection with 1 feature and 1 field
## Geometry type: MULTIPOLYGON
## Dimension: XY
## Bounding box: xmin: 238.9009 ymin: -837.4039 xmax: 1105.521 ymax: 40.07607
## CRS: NA
result %>% ggplot() +
geom_sf()
grid_spacing = 1
grid <- result %>% st_make_grid(what = "centers", cellsize = c(grid_spacing, grid_spacing)) %>%
st_sf()
heights <- st_join(grid, (result %>% select(geometry) %>% mutate(Z = 1))) %>% replace(is.na(.), 0)
z <- heights %>% st_coordinates() %>% as_tibble() %>%
bind_cols(heights %>% st_drop_geometry()) %>%
mutate(X = round(X,1)) %>%
mutate(Y = round(Y,1)) %>% pivot_wider(names_from = Y, values_from = Z) %>%
column_to_rownames("X") %>% as.matrix()
x <- 1:nrow(z)
y <- 1:ncol(z)
colorlut <- c("#F2F2F2", "#E34234") #"#ECB176",
col <- colorlut[ z - min(z) + 1 ] # assign colors to heights for each point
#open3d()
surface3d(x, y, z, color = col, back = "lines")
#e34234
#close3d()